/* Copyright (C) 2008, 2009, 2010 Faindu GmbH, Switzerland.
* All Rights Reserved. The following is Source Code and is subject to all restrictions 
* on such code as contained in the license accompanying this project. */
package blocstac.editimage.base
{

import flash.geom.Point;

import org.mockito.MockitoTestCase;

public class SizePropertiesTest extends MockitoTestCase
{
	function SizePropertiesTest() {
		super([ViewModel])
	}
	
	//==========================================================================
	//
	//  Test set up and tear down
	//
	//--------------------------------------------------------------------------  
	private var _viewModel:ViewModel
	private var _sizeProperties:SizeProperties
	
	override public function setUp(): void {
		_viewModel = mock(ViewModel, null, [null])
		given(_viewModel.image2componentSpace(any())).will(new ReturnArg(0))
		given(_viewModel.image2componentViewSpace(any())).will(new ReturnArg(0))
		given(_viewModel.component2imageSpace(any())).will(new ReturnArg(0))
		given(_viewModel.componentView2imageSpace(any())).will(new ReturnArg(0))
		
		given(_viewModel.imageWidthUnscaled).willReturn(10)
		given(_viewModel.imageHeightUnscaled).willReturn(11)
		
		_sizeProperties = new SizeProperties(_viewModel)
	}
	override public function tearDown():void {
	}
	
	//==========================================================================
	//
	//  Tests
	//
	//--------------------------------------------------------------------------  
	[Test]
	public function test_component2imageSpace_upper_left_bound(): void {
		var p:Point = _sizeProperties.component2imageSpace(new Point(-1, -1))
		assertEquals(0, p.x)
		assertEquals(0, p.y)
	}
	
	[Test]
	public function test_component2imageSpace_lower_right_bound(): void {
		var p:Point = _sizeProperties.component2imageSpace(new Point(20, 20))
		assertEquals(10, p.x)
		assertEquals(11, p.y)
	}

	[Test]
	public function test_image2componentSpace_upper_left_bound(): void {
		var p:Point = _sizeProperties.image2componentSpace(new Point(-1, -1))
		assertEquals(0, p.x)
		assertEquals(0, p.y)
	}
	
	[Test]
	public function test_image2componentSpace_lower_right_bound(): void {
		var p:Point = _sizeProperties.image2componentSpace(new Point(20, 20))
		assertEquals(10, p.x)
		assertEquals(11, p.y)
	}
	
}
}
